<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>VIP用户</title>
</head>
<body>
<h1>vip用户信息</h1>
<form>

    <div>
        名字：<input id="name"  type="text" placeholder="请输入姓名" >
    </div>
    <div>
        号码：<input id="number" type="text" placeholder="请输入vip号码">
    </div>
    <div>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input  id="check" type="button" value="查询" >
    </div>

<table class="form" border="1px" align="center">
            <tr>
                <th>id</th>
                <th>姓名</th>
                <th>VIP号</th>
                <th>删除</th>
            </tr>
    <tbody class="tbody">
            <tr>

            </tr>
    </tbody>
</table>

</form>
<script src="__PUBLIC__/js/jquery-2.1.1.min.js"></script>
<script src="__PUBLIC__/layui/layui.js"></script>
<script type="text/javascript">
    $(function (){
        $("#check").click(function() {
            var param={
                name:$("#name").val(),
                number:$("#number").val(),
            };
            $.ajax({
                url:'/app/index.php/Student/Text/find4',
                type:"POST",
                dataType:"JSON",
                data:param,
                success:function (data) {
                    var box = $('.tbody').empty();
                    $.each(data,function (k,v) {
                        box.append(
                            '<tr id="'+v.id+'">'+
                                    '<td>'+v.id+'</td>'+
                                    '<td>'+v.name+'</td>'+
                                    '<td>'+v.number+'</td>'+
                                    '<td>'+'<input type="button" value="删除" onclick="removeTr('+v.id+')">' +'</td>'
                            +'</tr>'
                            )
                    })
                },
                error:function (data) {
                    alert("提交失败");
                }
            });

        });

    });
function removeTr(id){
        if (confirm("是否删除数据？")) {
            $.ajax({
                url:'/app/index.php/Student/Text/delect',
                type:"POST",
                dataType:"JSON",
                data:{id:id},
                success:function (data) {
                    if(data.code==0){
                        alert(data.msg);
                        $("tr[id="+id+"]").remove();
                    }else{
                        alert(data.msg);
                    }
                }
            })
        }

    }

</script>

</body>
</html>